package 简单的策略模式.商场促销;

import java.util.Scanner;

/**
 * @author zyl
 * @Description
 * @since 2023/12/26 9:48
 */

public class Client {
    public static void main(String[] args) {
        double price = 0d;
        double totalPrice = 0d;
        double total = 0d;
        int num = 0;
        Integer discount = 0;

        do {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入商品销售模式：1.原价 2.打折 3.返利");
            discount = Integer.valueOf(sc.nextLine());
            System.out.println("请输入商品单价");
            price = Double.parseDouble(sc.nextLine());
            System.out.println("请输入商品数量");
            num = Integer.parseInt(sc.nextLine());



            if (price > 0d && num > 0){

                CashContext cashContext = new CashContext(discount);
                totalPrice = cashContext.getPriceResults(price, num);

                total = total + totalPrice;
                System.out.println();
                System.out.println();
                System.out.println("单价:" + price + "元 数量:" + num + "合计:" + totalPrice +"元" );
                System.out.println();
                System.out.println("总合计:" + total +"元" );
            }

        }while (price > 0d && num > 0);
    }
}
